#ifndef TRIE_HH_
# define TRIE_HH_

///
/// \file Trie.hh
/// \brief Class that represents the trie structure.
/// \author Coddy Levi, Sylvain Lobry
/// \version 1.0
///
///
///

#include <list>

///
/// \class Trie
/// \brief Trie representation and operations.
///
class Trie
{
public:
  ///
  /// \brief equivalent to Trie(0, 0)
  ///
  Trie();

  ///
  /// \brief Construct a new Trie node
  /// \param[in]	value The char that value the node
  /// \param[in]	frequency The frequency of the word ending at this node. If it is not a word then frequency should be 0.
  ///
  Trie(char value,
       unsigned frequency);

  ///
  /// \brief Destruct recursively all the nodes in the Trie.
  ///
  ~Trie();

  ///
  /// \brief Add a word into the Trie
  /// \param[in]	word The word to be added.
  /// \param[in]	frequency The word's frequency in the user dictionary
  ///
  void add_word(const char* word,
		unsigned frequency);

  ///
  /// \brief Basic command line Trie printer 
  ///
  void print (unsigned offset = 0) const;

  ///
  /// \brief Accessor to the node's value
  /// \return	the node's value
  ///
  char get_value() const;

  ///
  /// \brief Compute recursively the size of the Trie
  /// \return	the number of nodes in the trie
  ///
  unsigned size() const;

  ///
  /// \brief Accessor to the node's frequency if it defines a word, 0 otherwise.
  /// \return	the node's frequency
  ///
  unsigned get_frequency() const;

  ///
  /// \brief Accessor to the node's number of sons
  /// \return	the node's number of sons
  ///
  unsigned get_nb_sons() const;

  ///
  /// \brief Accessor to the node's list of sons
  /// \return	the node's list of sons
  ///
  const std::list<Trie*>* get_sons() const;

private:
  ///
  /// The Trie node's letter
  ///
  char value;

  ///
  /// The frequency of the word defined by all the letter of the nodes on the branch until this one. 0 if it is not a word present in the dictionary
  ///
  unsigned frequency;

  ///
  /// The list of sons of the Trie's node.
  ///
  std::list<Trie*> sons;
};

#endif /* !TRIE_HH_ */
